Private Sub PrintIt(ByVal Filetyp As Long)
Dim fname As String, fi As FileInfo, DefaultPrinter As String
Dim opt As PDFCreator.clsPDFCreatorOptions
Dim test As PDFCreator.clsUpdate
fi = New FileInfo(OpenFileDialog1.FileName)
If fi.Name.Length > 0 Then
If InStr(fi.Name, ".", CompareMethod.Text) > 1 Then
fname = Mid(fi.Name, 1, InStr(fi.Name, ".", CompareMethod.Text) - 1)
Else
fname = fi.Name
End If
End If
If Not _PDFCreator.cIsPrintable(fi.FullName) Then
MsgBox("File '" & fi.FullName & "' is not printable!", MsgBoxStyle.Exclamation, Me.Text)
Exit Sub
End If
opt = _PDFCreator.cOptions
With opt
.UseAutosave = 1
.UseAutosaveDirectory = 1
.AutosaveDirectory = fi.DirectoryName
.AutosaveFormat = 2
.JPEGQuality = 100
.JPEGResolution = 150
opt.AutosaveFilename = fname
End With
With _PDFCreator
.cOptions = opt
.cClearCache()
DefaultPrinter = .cDefaultPrinter
.cDefaultPrinter = "PDFCreator"
.cPrintFile(fi.FullName)
ReadyState = False
.cPrinterStop = False
End With
With Timer1
.Interval = maxTime * 1000
.Enabled = True
Do While Not ReadyState And .Enabled
Application.DoEvents()
Loop
.Enabled = False
End With
If Not ReadyState Then
MsgBox("Creating printer test page as pdf." & vbCrLf & vbCrLf & _
"An error is occured: Time is up!", MsgBoxStyle.Exclamation, Me.Text)
End If
_PDFCreator.cPrinterStop = True
_PDFCreator.cDefaultPrinter = DefaultPrinter
opt = Nothing
End Sub